<template>
	<code-note-page name="nextArrayNote" :dialogGoUri="dialogGoUri" :isOpenDefaultDialog="!withC" v-bind:code="code" :infos="infos">
		<question-dialog slot="questions" v-if="withC"></question-dialog>
	</code-note-page>
</template>

<script>
import infos from '~/data/next.json'
import questionDialog from '~/components/NextArrayWithCQuestion'
import store from '~/utils/store'
export default {
	components: {
		questionDialog
	},
	props: {
		c: {
			type: Boolean
		}
	},
	data() {
		let self = this
		let c = self.c
		
		if (c === null)
		{
			let tmp = store.getItem('c')
			
			if (tmp === 'true')
				c = true
			else
				c= false
		}
		
		return {
			code : `void calculateNext(char *t, int *next)
{
	next[0] = -1;
	int i = 0, j = -1;

	while (i < strlen(t) - 1)
	{
		if (j == -1 || t[i] == t[j])
		{
			i++;
			j++;
			next[i] = j;
		}	
		else
			j = next[j];
	}
 }`,
			infos: infos,
			withC: c,
			dialogGoUri: '/nextArrayVisualizer'
		}
	}
};
</script>

<style>
</style>
